import { Component, OnInit, AfterViewInit } from '@angular/core';
import { MainService } from '../../service/main.service';
import * as $ from 'jquery' ;


@Component({
  selector: 'app-shouye',
  templateUrl: './shouye.component.html',
  styleUrls: ['./shouye.component.css']
})
export class ShouyeComponent implements OnInit,AfterViewInit {

  // swiper:Swiper
  // slides
  
  gsxwData=[];
  gsjjData=[];
  gsxwImg='';
  firstTitle; 
  firstId;
  contentTitle;
  contentCt;
homeFirstList;
secondId
gsjjImg;
gsjjContent;
control:boolean
mainUrl
gsxwPicUrl
gsjjImgUrl
gsxwTitle
gsyjImg=[]
gsyjLbt:Swiper;

testSwiper: Swiper;
slides = [];



ngOnInit() {
  //科技创新轮播图
  this.service.getFromServ('/api/banner/get_science',{},res=>{
    // console.log(res);
    for(let i in res.data){
      this.slides.push(this.service.picurl+res.data[i].image)
    }
  },err=>{}) 
// 公司业绩轮播图
this.service.getFromServ('/api/banner/get_company',{},res=>{
// console.log(res);
for(let i in res.data){
  this.gsyjImg.push(this.service.picurl+res.data[i].image)
}
// console.log(this.gsyjImg);

},err=>{})
}
ngAfterViewInit() {
  // 科技创新轮播
  this.testSwiper = new Swiper('#kjcxLbt', {
    direction: 'horizontal',
    slidesPerView: 3,
      spaceBetween: 30,  
      centeredSlides: true,
      freeMode:false,
      //加一个切换效果
      effect:'coverflow',
    loop: false,
    observeParents:true,
    observer:true,
    // 如果需要分页器
    // pagination: {
    //   el: '.swiper-pagination',
    // },
    // // 如果需要前进后退按钮
    // navigation: {
    //   nextEl: '.swiper-button-next',
    //   prevEl: '.swiper-button-prev',
    // },
    // // 如果需要滚动条
    // scrollbar: {
    //   el: '.swiper-scrollbar',
    // },
    autoplay:{
      delay: 3000,
    }
  });
  // 公司业绩轮播
  this.gsyjLbt = new Swiper('#gsyjLbt', {
    direction: 'horizontal',
    // slidesPerView: 3,
      // spaceBetween: 30,  
      // centeredSlides: true,
      freeMode:false,
      //加一个切换效果
      // effect:'coverflow',
    loop: false,
    observeParents:true,
    observer:true,
    // 如果需要分页器
    pagination: {
      el: '.swiper-pagination',
    },
    // 如果需要前进后退按钮
    navigation: {
      nextEl: '.swiper-button-next',
      prevEl: '.swiper-button-prev',
    },
    // 如果需要滚动条
    scrollbar: {
      el: '.swiper-scrollbar',
    },
    autoplay:{
      delay: 3000,
    }
  });
}

  constructor(private service:MainService) {
    
this.mainUrl=service.mainUrl
    this.control=true;
    // 首页返回数据请求
    this.service.getFromServ('/api/index/get_index',{},res=>{
      // 公司新闻详情
      this.gsxwTitle=res.data.company[0].title.substring(0,7)+'...'
      this.gsxwPicUrl=this.service.picurl+ res.data.company[0].image
      $('#gsxwContent').html(res.data.company[0].content.substring(0,40)+'...')
      console.log(res);
      // 公司简介详情
      this.gsjjImgUrl= this.service.picurl + res.data.suggest[0].image
      $('#gsjjContent').html(res.data.suggest[0].content.substring(0,60)+'...')
      // 公司业绩详情
      
      },err=>{
      
      })

   }

}
